#!/usr/bin/perl
use strict;
 
# use module
use XML::Simple;

my $xml = new XML::Simple ;

$data = $xml->XMLin($confFile);
 
# função pra executar o parser
 
sub xmlParser(){
        $confFile  = shift ;
        $area      = shift ;
        $data      = $xml->XMLin($confFile) ;
        $name      = $data->{host}{name} ;
        $ipaddress = $data->{host}{ipaddress} ;
        $community = $data->{generalconfs}{community} ;
        push(@oidList,$data->{generalconfs}{oidbytesin})  if defined $data->{generalconfs}{oidbytesin}  ;
        push(@oidList,$data->{generalconfs}{oidbytesout}) if defined $data->{generalconfs}{oidbytesout} ;
        if ( $area eq "area1"   ) { @mibList = split(/,/,$data->{host}{miblistA1});   }
        if ( $area eq "area2"   ) { @mibList = split(/,/,$data->{host}{miblistA2});   }
        if ( $area eq "area3"   ) { @mibList = split(/,/,$data->{host}{miblistA3});   }
        if ( $area eq "area4"   ) { @mibList = split(/,/,$data->{host}{miblistA4});   }
        if ( $area eq "area5fe" ) { @mibList = split(/,/,$data->{host}{miblistA5fe}); }
        if ( $area eq "area5be" ) { @mibList = split(/,/,$data->{host}{miblistA5be}); }
        if ( $area eq "area6fe" ) { @mibList = split(/,/,$data->{host}{miblistA6fe}); }
        if ( $area eq "area6be" ) { @mibList = split(/,/,$data->{host}{miblistA6be}); }
        if ( $area eq "area7"   ) { @mibList = split(/,/,$data->{host}{miblistA7});   }
        return ($name,$ipaddress,$community,\@oidList,\@mibList);
}
 
# chamada da função que alimenta as variáveis
 
($name,$ipaddress,$community,$oidList,$mibList) = &xmlParser($confFile,$area) ;


